Skip to content

rederive: shadow mode + would-beat-king gate + seed-clobber fix - #95

Open
karpabot wants to merge 1 commit into
RalphLabsAI:mainfrom
karpabot:fix/rederive-shadow-gate
Open

rederive: shadow mode + would-beat-king gate + seed-clobber fix#95
karpabot wants to merge 1 commit into
RalphLabsAI:mainfrom
karpabot:fix/rederive-shadow-gate

Conversation

@karpabot

@karpabot karpabot commented Jul 3, 2026

Copy link
Copy Markdown

Foundational, zero-live-risk step of the P2→P4→P3 execution hardening. All changes are inert until RALPH_REDERIVE is set and canonical data is materialized; the container_measurement is untouched (no .py/.yaml/.json/.md under a hashed proof dir changes).

What

Turns op_rederive_trajectory (pre-crown proof-of-EXECUTION) from an unusable stub into a calibratable, cost-bounded gate:

  • Shadow modeRALPH_REDERIVE ∈ {off (default), shadow, enforce}. shadow runs the re-run + logs the would-be verdict but never blocks a crown, so the honest cross-GPU/bf16 trajectory spread can be collected on the live box with zero false-reject risk before enforcing.
  • Would-beat-king gate — moved the call out of judge_submission (ran for every op1-op3-passing bundle = O(submissions) GPU + a DoS surface) into the crown path of both router.process_submission and service.score_and_decide, so it runs only for a bundle that would take the crown (O(king-changes)).
  • Promotion-gate semantics — a failed verdict only withholds the crown (status: rederive_withheld); it never dethrones the sitting king and never auto-blacklists. Every ambiguity (disabled / no canonical data / timeout / too-few points) stays fail-OPEN.
  • Seed-clobber fix — dropped --seed from the re-run. train.py --seed clobbers both init_seed and data_seed, so an honest miner with init_seed != data_seed would be guaranteed a step-0 false-reject. The full config (both seeds correct) is already passed via --config.
  • Env-tunable tolerancesRALPH_REDERIVE_STEP0_TOL / _ABS_TOL / _REL_TOL so the band is calibrated from shadow data without a code change.

Tests

26 new (tests/test_rederive_gate.py): mode parsing, tolerance env-threading, shadow-never-gates, fail-open skips, seed-guard, and the router + service crown gates (pass→crown, fail→withhold + king holds, non-decisive→skip). Full suite green apart from 3 pre-existing env-only failures (missing active_tokens.bin / GPU-nondeterminism, fail identically on main).

Rollout

Ships off. Next: materialize canonical data on the box (separate, measurement-neutral), then RALPH_REDERIVE=shadow to calibrate on king 09caba0d, then =enforce.

🤖 Generated with Claude Code

- RALPH_REDERIVE=off/shadow/enforce (_rederive_mode); shadow runs + logs
  the verdict but never blocks a crown (live calibration, no false-reject).
- move op_rederive out of judge_submission -> pre-crown gate in
  router.process_submission AND service.score_and_decide, run ONLY for a
  would-be king (cost O(king-changes), not O(submissions); closes a DoS).
- a failed verdict only WITHHOLDS the promotion (status rederive_withheld);
  never dethrones the sitting king, never auto-blacklists. Fail-OPEN on
  every ambiguity (disabled / no canonical data / timeout / too-few points).
- drop --seed from the re-run: train.py --seed clobbers BOTH init_seed and
  data_seed, so any honest init_seed!=data_seed run would false-reject; the
  full cfg via --config carries both seeds correctly.
- env-tunable tolerances (RALPH_REDERIVE_STEP0_TOL/_ABS_TOL/_REL_TOL) so the
  honest cross-GPU/bf16 spread is calibrated in shadow without a code change.
- 26 tests (mode/tols/shadow-wrap/fail-open/seed-guard + router & service gates).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant